package com.yzt.minemodule.activity;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.yzt.zhuju.base.BaseActivity;
import com.yzt.minemodule.R;
import com.yzt.minemodule.fragment.OrderFragment;
import com.yzt.plugin_widget.tableBar.SlidingTabLayout;
import com.yzt.plugin_widget.viewPager.ViewPagerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * 作者：bobwang
 * 创建时间：2023-11-15 23:25:01
 * 描述：
 */
public class MineOrderActivity extends BaseActivity {

    private SlidingTabLayout mTabLayout;

    private ViewPager mViewPager;

    @Override
    public int getLayoutId() {
        return R.layout.activity_mine_order;
    }

    @Override
    public void installViews() {
        mTabLayout = findViewById(R.id.tablayout);
        mViewPager = findViewById(R.id.viewPager);
        initViews();
        mTitleBar.setTitle("我的订单");
    }

    /**
     * 加载页面分类
     */
    private void initViews() {
        List<String> tabs = new ArrayList<>();
        List<Fragment> fragments = new ArrayList<>();
        tabs.add("待支付");
        tabs.add("已支付");
        tabs.add("已关闭");
        fragments.add(OrderFragment.getInstance(0));
        fragments.add(OrderFragment.getInstance(1));
        fragments.add(OrderFragment.getInstance(2));
        mViewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager(), fragments, tabs));
        mViewPager.setOffscreenPageLimit(tabs.size());
        mTabLayout.setViewPager(mViewPager);
    }
}
